{php include wl_template('common/header');}
{if $config['base']['meiqia']>0}
<script type='text/javascript'>

    (function(m, ei, q, i, a, j, s) {
        m[a] = m[a] || function() {
            (m[a].a = m[a].a || []).push(arguments)
        };
        j = ei.createElement(q),
            s = ei.getElementsByTagName(q)[0];
        j.async = true;
        j.charset = 'UTF-8';
        j.src = i + '?v=' + new Date().getUTCDate();
        s.parentNode.insertBefore(j, s);
    })(window, document, 'script', '//static.meiqia.com/dist/meiqia.js', '_MEIQIA');
    _MEIQIA('entId', {$config['base']['meiqia']});
	</script>
	{/if}
<style>
		.link-rule{
		height:100%;
		width:100%;
		background-color:
		rgba(128,128,128,0.5);
		position:fixed;top:0px;
		left:0px;
		z-index:10000;
	}
	.link-rule>div{
		text-align:center;
		position:absolute;
		top:0;
		bottom:0;
		left:8px;
		right:8px;
		margin-top:auto;
		margin-bottom:auto;
		height:85%;
		background-color:white;
		border-radius:8px;
	}
	.link-rule>div>div:first-child{
		 font-weight:bold;
		 background-color:#ececec;
		 font-size:20px;
		 line-height:40px;
		 border-radius:8px 8px 0 0;
		 height:40px;
	}
	.link-rule>div div:nth-child(2){
		 text-align:left;
		 position:absolute;
		 top:48px;
		 bottom:45px;
		 left:19px;
		 right:19px;
		 overflow:scroll;
	}
	.link-rule>div div:last-child{
		 position:absolute;
		 left:0px;
		 right:0px;
		 width:150px;
		 height:30px;
		 bottom:5px;
		 background-color:#0894ec;
		 color:white;
		 font-size:18px;
		 margin-left:auto;
		 margin-right:auto;
		 line-height:30px;
		 border-radius:5px;
	}
	#pricedown {   
		display: block;
		width: 40px;
		height: 40px;
		background-color: hsl(194, 57%, 64%);
		color: hsl(0, 0%, 100%);
		line-height: 15px;
		text-align: center;
		border-radius: 20px;
		padding-top: 5px;
		font-size: 12px;
		right: 20px;
		bottom: -20px;
		position: absolute;
	}
	#numPerson,#numPrices,#numGroup, #tuanPre {display:none;}
	#jieTiGroup {background-color:white;padding:10px;}
	#jieTiGroup>div {margin-bottom:10px;}
	#jieTiGroup>div>div:first-child{width:100%;height:20px;}
	.preTuan{height:20px;width:50%;line-height:20px;box-sizing:border-box;float:left;}
	.numTuan {height:20px;width:100%;line-height:20px;box-sizing:border-box;text-align:right;}
	.process{margin-top:20px;margin-bottom:20px;position:relative;width:90%;margin-left:5%;height:20px;border-radius:10px;background-color:white;border:1px solid hsl(354, 91%, 73%)}
	.progressBar {background-image:linear-gradient(90deg,#6fbfd8,hsl(354, 91%, 73%));height:100%;border-radius:10px;left:0px;top:0px;}
	.progressStep {border:1px solid white;height:14px;width:4px;border-radius:7px;position:absolute;top:2px;background-color:white;}
	.progressStep>div:first-child {position: absolute;top: -20px;width: 40px;text-align: center;left: -20px;line-height: 20px;height: 20px;}
	.progressStep>div:last-child {position: absolute;top: 14px;width: 40px;text-align: center;left: -20px;line-height: 20px;height: 20px;}
	.payToGroup {height: 30px;line-height: 30px;text-align: center;width: 80%;background-color: rgb(248, 123, 136);border-radius: 20px;color: white;margin-left: 10%;}
	#over {text-align:right}
	.link-rule p {text-indent:2em;}
	#returnBack {
		width: 40px;
		height: 40px;
		border-radius: 20px;
		background: linear-gradient(90deg,transparent 1px, hsla(0, 0%, 50%, 0.7) 0);
		position: absolute;
		left: 20px;
		top: 20px;
		z-index: 3;
		color: white;
		text-align: center;
		line-height: 16px;
		padding-top: 4px;
		font-weight: bold;
		font-size: 12px;
	}
	#returnBack::before {
		content: '';
		position: absolute;
		left: -3px;
		top: 16px;
		height: 8px;
		width: 8px;
		background: linear-gradient(45deg,hsla(0, 0%, 50%,0.7) 50%, transparent 0);
		transform: rotate(45deg);
		-webkit-transform:rotate(45deg);
	}
</style>
<span id="tuanPre">666,777</span>
<span id="numPerson">10,20,50,100</span>
<span id="numPrices">0.03,0.02,0.01,0.005</span>
<span id="numGroup">100,40</span>
<span id="goodsid">{$goods['id']}</span>
<span id="isshow">{$goods['isshow']}</span>
<div class="page-group">
    <div class="page page-current" id="page-goods-detail">
		<div id="returnBack">
		<!--<svg width="40px" height="40px" viewBox="0 0 100 100"
		 xmlns="http://www.w3.org/2000/svg">
		 <path d="M65 25 25 50 65 75" style="stroke-width:8;stroke: white;fill:none;stroke-linejoin:round"/>
		 </svg>-->
		 返回<br/>商城
		</div>
    	<div class="content">
    		<div class="dt_detail" >
			    <section class="detail_main" style="position:relative">
				{if  !empty($advs)}
			        <div class="sliderImage">
			            <div class="images" id="sliderImg" style="visibility: visible;">
			            	<ul>
			            		{loop $advs $adv}
			            		<li><img src="{php echo tomedia($adv['thumb']);}" style='width:100%;'></li>
			            		{/loop}
							</ul>
			            </div>
			            <div class="images_num" id="sliderNum">
			            	{php $slideNum = 1;}
					    	{loop $advs $adv}
					        <span{if $slideNum == 1} class="curr"{/if}></span>
					        {php $slideNum++;}
					    	{/loop}
			            </div>  
			        </div>
					{/if}
			    	<div class="productInfo" >
			    		<h2 style="padding-top: 10px;">{$goods['gname']}</h2>
			    		<span id="pricedown"  {if $goods['isdownjia']==0}style="display:none;"{/if}>降价<br/>通知</span>
			    		<div class="editor">{$goods['goodsdesc']}</div>
			    	</div>
					<div id="jieTiGroup">
						
						</div>
			    	<div class="salesVolume" style="display: block;"><span style="float: left;">{if $config['base']['ismarketprice']==0}市场价：￥{$goods['mprice']}{/if}</span>{if $config['base']['issell']==0}已售：{$goods['salenum']}{/if}</div>
					<!--<div style="padding-left:10px;color:#888;background-color:white;font-size:0.8em;">商品确认收货后可获得10086积分</div>-->
			    	<div class="progressOuter noShow"><span class="suc_tuan">已成团</span>
			    	<div class="progress"><div class="percent"></div></div><span class="total_tuan">共团</span></div>
			    	<div class="playTips" style="margin-top:-8px;">支付开团并邀请好友参加，人数不足自动退款，详见下方团购玩法</div>
			    	<script>
							
					    $(function() {
					        new Swipe($('#sliderImg')[0], {
					            speed:500,
					            auto:3000,
					            callback: function(){
					                var lis = $("#sliderNum").children();
					                lis.removeClass("curr").eq(this.index).addClass("curr");
					            }
					        });
					    });
					</script>
			    </section>
			    <section class="goBuy" data-people="3" data-times="10" data_acttype="0" data_coupon="0" data_dealtype="" style="display: block;position:static">
			        <div class="btns" style="display: none;">
			            <div class="group_btn" id="buyGroup"><span class="price"><em>8.9元</em>/{$goods['unit']}</span><span class="colline"></span><span class="count">3人团&gt;</span></div>
			           <div class="single_btn" id="buySingle"><span class="price"><em>10.9元</em>/{$goods['unit']}</span><span class="colline"></span><span class="count">单独购买&gt;</span></div>
			        </div>
					
			        {if $goods['isshow']==3}
			        <div class="ico_end"></div>
			        {elseif $goods['isshow']==2}
			        <div class="ico_countdown"></div>
			        {/if}
			        <div class="tuan_btn" id="buyNow"><span>立即参团</span><span><i class="rowline"></i><em>8.9元</em>/{$goods['unit']}</span></div>
			        <div class="goIndexBtn">去首页逛逛吧</div>
			        <p class="activityTip"></p>
			    </section>
			    <div class="space" style="display: none;"></div>
			    
			    <!--商家
				{if $merchant}
				<a href="{php echo $this->createMobileUrl('merchant',array('id'=>$merchant['id']));}">
	            <div class="mall_goods">
	                <img src="{php echo tomedia($merchant['thumb'])}">
	                <div class="mall_sub">
	                    <span>{$merchant['name']}</span>
	                    <div class="sales">销量：{$goods['salenum']}</div>
	                </div>
	                <div class="enter_button">
	                    <img src="http://pinduoduo.b0.upaiyun.com/mall/mall_icon_small.png">
	                    <span>进店逛逛</span>
	                </div>
	            </div>
	            </a>
	            {/if}-->
	            
	            <!--门店-->
				<!--
	            {if $goods['is_hexiao']==1}
				<div class="good_speci" onclick="showStores(this)" show="1">适用的商家信息<i class="fa fa-angle-down" style="float:right; line-height:44px; font-size:26px;"></i></div>
	  			<div>
		  			{loop $stores $stores}
			        <div class="store">
			            <div class="info">
			            <div class="ico"><i class="fa fa-university"></i></div>
			            <div class="info1">
			                <div class="inner">
			                     <div class="user">{$stores['storename']}</div>
			                     <div class="addresss">地址: {$stores['address']}</div>
			                     <div class="tel">电话: {$stores['tel']}</div>
			                 </div>
			             </div>
			             <a href="http://api.map.baidu.com/marker?location={$stores['lat']},{$stores['lng']}&amp;title={$stores['storename']}&amp;name={$stores['storename']}&amp;content={$stores['address']}&amp;output=html" class="external"><div class="ico2"><i class="fa fa-map-marker"></i></div></a>
			             <a href="tel:{$stores['tel']}" class="disable-router"><div class="ico3"><i class="fa fa-phone"></i></div></a>
			        	</div>
			        </div>
					{/loop}
		       	</div>
		       	{/if}
		       	-->
		       	<!--分享团-->
		       	{if !empty($thistuan)}
				{if ($share_data['share_type']==1 || $share_data['share_type']=='')}
					<div id="more_tuan" style="margin-top: 10px;{if $goods['ison']==0}display:none;{/if}">
					<div class="ht">
						<div class="ht_tit">附近的小伙伴正在发起团购，您可以直接参与</div>
						<div class="ht_list">
						{loop $thistuan $tuan}
						<div class="ht_item">
							<div class="ht_avatar"><img src="{$tuan['avatar']}" alt="团长头像"></div>
							<div class="ht_info"><div class="ht_name">{$tuan['nickname']}</div><div class="ht_time">发起时间：{php echo date('Y-m-d H:i:s', $tuan['starttime']);}</div></div>
							<a href="{php echo app_url('order/group',array('tuan_id'=>$tuan['groupnumber']));}" class="ht_btn" ptag="20400.7.1"><span class="ht_price"><i>￥</i>{if !empty($tuan['price'])}{$tuan['price']}{else}{$goods['gprice']}{/if} / {$goods['unit']}</span><span class="ht_btn_go">差{$tuan['lacknum']}人成团，火速参团 》</span></a>
						</div>
						{/loop}
						
						</div>
					</div>
					</div>
					{else}
					<div id="more_tuan" style="margin-bottom: 60px;">
						<div class="ht">
							<div style="text-align: center;">
							<a href="{php echo $this->createMobileUrl('goodsdetails',array('share_type'=>'share_type','id'=>$id));}" style="background-color: #FF5252;border-radius: 3px;width: 90%;height: 50px;text-align: center;color: rgb(255, 255, 255);margin-left: 5%;margin-top:5px;float: left;-webkit-border-radius: 3px;">
							<b><font size="5"><div class="ico2" style="margin-top: 10px;;"><i class="fa fa-map-marker"></i> 附近的团</div></font></b>
							</a>
							</div>
						</div>
					</div>
				{/if}
		        {/if}
		        
			    <section class="stepGuild">
			        <div class="step_tit"><i></i>拼团玩法<span><span id="lookdetail">查看详情&gt;</span></span></div>
			        <div class="step_flow">
			            <div class="step_item step_item_on"><span class="step_num" >1</span><span>选择<br>心仪商品</span></div>
			            <div class="step_item"><span class="step_num">2</span><span class="steps">支付开团<br>或参团</span></div>
			            <div class="step_item"><span class="step_num">3</span><span class="steps">邀请好友<br>参团支付</span></div>
			            <div class="step_item"><span class="step_num">4</span><span class="steps">达到人数<br>团购成功</span></div>
			        </div>
			    </section>
			</div>
			
	        <div class="section_body info_detail">
		        <div>
	            <div id="div_nav_fixed">
	                <div id="div_nav" class="div_nav">
	                    <ul class="boxx" style="padding-left: 0px;">
	                    	<li>
	                            <a onclick="exchange(1);" data-idx="1" class="sp on" id="shangpin1">图文详情</a>
	                        </li>
	                        <li>
	                            <a onclick="exchange(0);" data-idx="0" class="sp" id="shangpin0">商品属性</a>
	                        </li>
	                    </ul>
	                </div>
	            </div>
	            <div id="div_sections" class="div_sections">
	                <section class="section_specification">
	                	{loop $params $p}
	                    <dl>
	                        <div>
	                            <dd><label>{$p['title']}</label><label>{$p['value']}</label></dd>
	                        </div>
	                    </dl>
	                    {/loop}
	                </section>
	                <section class="section_detail on" data-role="widget" data-widget="img_prev_view">
	                    <div id="description" class="J_DetailSection tshop-psm tshop-psm-bdetaildes" style="margin:0px;padding:0px;">
	                        <div class="ke-post" id="productInfott" style="margin:10px 0px 0px;padding:0px;font-size:14px;font-family:tahoma, arial, 宋体, sans-serif;">
	                            
	                        </div>
	                    </div>
	                </section>
	            </div>
		        </div>
				
<!--猜你喜欢-->		
<style type="text/css">
.guesslike{width:93%;color:#F83817;font:0.7rem "微软雅黑";display:block;border-bottom:1px solid #ccc;padding-bottom:6px;margin:0 auto;}
.aboutProduct{clear:both;width:93%;list-style:none;margin:0 auto;padding-bottom:1rem;display:table;}
.aboutProduct li{width:31%;height:7.4rem;float:left;background-color:#fff;text-align:center;margin-left:3.4%;margin-top:14px;overflow:hidden;}
.aboutProduct li:first-child{margin-left:0px!important;}
.aboutProduct li.ml0{margin-left:0px!important;}
.aboutProduct li img{width:100%;height:5rem;}
.aboutProduct li h3{font-size:0.6rem;height:1rem;display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-top:5px; }
.aboutProduct li span{width:100%;font-size:0.8rem;color:#B80000;text-align:center;}
.aboutProduct li span:before{content:"￥";font-size:0.6rem;color:#FF4400;}
</style>
<h2 class="guesslike">猜你喜欢 ❤</h2>
<ul class="aboutProduct"></ul><!--aboutProduct-->
<script type="text/javascript">
function goDetil(url){
window.location.href=url;
return;
}
$.ajax({
             type:"GET",
             url:"{php echo app_url('goods/ajaxlist/goods_rand')}",
            // data:{},
             dataType:"json",
             success: function(data){
		           	 var abouthtml =''; 
			            $.each(data,function(key,val){
				          abouthtml += "<li onclick=goDetil('"+data[key].url+"')><img src='"+data[key].gimg+"'><h3>"+data[key].gname+"</h3><span>"+data[key].gprice+"</span></li>";
                         });
                         $('.aboutProduct').html(abouthtml);
					     var abli=$(".aboutProduct li");
						 if(abli.length==9){abli.eq(3).addClass("ml0");abli.eq(6).addClass("ml0");}else{abli.eq(3).addClass("ml0");}
						 
                      },error:function(XMLHttpRequest,textStatus,errorThrown){}
         }); //end ajax
</script>	
				
		    </div>
			<div style="height:65px;"></div>
			<input type="hidden" name="times" id="times" value="{$times}" />
		 	<input type="hidden" name="one_limit" id="one_limit" value="{$goods['one_limit']}" />
		 	<input type="hidden" name="many_limit" id="many_limit" value="{$goods['many_limit']}" />
	 	
			
    	</div>
	    {if $goods['hasoption']==1||$goods['one_limit']>1}
	    	{php include wl_template('goods/goods_option');}
	    {/if}
		<footer class="footer" style="z-index: 1!important;height: 50px;">
	        <nav>
	            <ul>
				
	                <li style="width: 20%;"><a href="{php echo app_url('goods/list')}" id="gohome" class="nav-controller external"><img src="{TG_URL_ARES}images/icon_home.png" height="18px" width="19px"><br>首页</a></li>
	                {if $goods['isshow']==1&&$goods['gnum']!=0}
						{if $goods['group_level_status']==2}
							<li class="group" style="color:white;"><a onclick='choose()' class="nav-controller"><i >￥{$goods['gprice']}</i>{$goods['groupnum']}人拼团</a></li>
							<li class="alone" style="color:white;"><a  style="color:white;" href="{php echo app_url('order/orderconfirm',array('groupnum'=>1));}" class="nav-controller external"><i >￥{$goods['oprice']}</i>单独购买</a></li>
							
						{elseif $goods['hasoption']==1||$goods['one_limit']>1}
							
							<li class="group" style="color:white;"><a onclick='choose(2)' class="nav-controller"><i >￥{$goods['gprice']}</i>{$goods['groupnum']}人拼团</a></li>
							<li class="alone"><a  style="color:white;" onclick='choose(1)' class="nav-controller"><i >￥{$goods['oprice']}</i>单独购买</a></li>
						{else}
							<li class="group" style="color:white;"><a onclick='bb(2)'  class="nav-controller"><i >￥{$goods['gprice']}</i>{$goods['groupnum']}人拼团</a></li>
							<li class="alone" style="color:white;"><a style="color:white;" onclick='bb(1)'  class="nav-controller"><i >￥{$goods['oprice']}</i>单独购买</a></li>
							
						{/if}
					{else}
					<li class="group" style="width: 80%;"><a href="{php echo app_url('goods/list')}" style="line-height: 40px;font-size: 16px;" class="nav-controller external">已售罄，查看更多商品</a></li>
					{/if}
	            </ul>
	        </nav>
	    </footer>
	    <input type="hidden" id="buytype" value="" />
	    <input type="hidden" id="buytype2" value="{$goods['groupnum']}" />
	    <input type="hidden" id="optionid" name="optionid" value=""/>
	</div>
</div>
<div class="link-rule" style="display:none;">
	<div>
		<div>拼团须知</div> 
		<div>
			<div style="color:#0894ec;">什么是拼团？</div>
			<p>每个商品都有单独购买价和拼团价，当您通过拼团价购买时，开团支付成功后再邀请朋友参团，参团人数达到组团规定时，订单生效。在规定时间内，若人数不足组团失败，我们会在48小时内自动退款。</p>
			<div style="color:#0894ec;">如何拼团成功？</div>
			<p>拼团是基于好友的转发扩散，获取团购优惠。首先选择商品开团：选择拼团商品下单，团即刻开启，但团长完成支付，方能获取转发链接，并在团开启规定时间内邀请到相应人数的好友支付，此团方能成功。</p>
			<div style="color:#0894ec;">团长干嘛的？</div>
			<p>首先选择心仪的商品下单，并完成支付后即为团长。团长视为本次交易的发起人，且为第一位支付成功的成员。</p>
			<div style="color:#0894ec;">拼团成员是什么？</div>
			<p>通过分享出去的该团入口进入或者通过分享团入口进入并完成付款加入该团的团员，参团成员也可以将该团分享出去邀约更多的团员参团。</p>
			<div style="color:#0894ec;">拼团失败是怎么回事？</div>
			<p>从团长开团规定时间内未能找到相应开团人数的好友参团，则该团失败，系统会在48个小时内自动原路退款至你的支付账户中。</p>
		</div>
		<div id="link-know">已了解</div>
	</div>
</div>

<script>

	var User = JSON.parse(localStorage.getItem("user"))|| {};
	var goodsid = document.getElementById("goodsid");
	var pricedown = document.getElementById("pricedown");
	var urlNotice = "{php echo app_url('goods/list/notice')}";
	var urlNoticeRemove = "{php echo app_url('goods/list/noticeremove')}";
	if (User[goodsid.innerHTML + "notice"]) {
		pricedown.style.backgroundColor = "#fcc602";
		pricedown.innerHTML = "等待<br/>通知";
	}
	document.getElementById("returnBack").onclick = function () {
		location.href = "{php echo app_url('goods_list')}";
	}
	pricedown.onclick = function() {
		if (pricedown.style.backgroundColor != "rgb(252, 198, 2)" && confirm("确认降价提醒么")) {
			postAjax(goodsid.innerHTML, urlNotice);
			pricedown.style.backgroundColor = "#fcc602";
			pricedown.innerHTML = "等待<br/>通知";
			User[goodsid.innerHTML + "notice"] = '1';
			localStorage.setItem("user",JSON.stringify(User));
		}
		else if (pricedown.style.backgroundColor == "rgb(252, 198, 2)" && confirm("确认取消降价提醒么")) {
			postAjax(goodsid.innerHTML, urlNoticeRemove);
			pricedown.style.backgroundColor = "#6fbfd8";
			pricedown.innerHTML = "降价<br/>通知";
			delete User[goodsid.innerHTML + "notice"];
			localStorage.setItem("user",JSON.stringify(User));
		}
	}
	function isshow() {
		var canBuy = Number(document.getElementById("isshow").textContent);;
		return canBuy == 1 ? true : false;
	}
	function postAjax(id, url, weight, str){
		var formData = new FormData();
		formData.append('id', id);
		if (weight !== undefined) {
			formData.append("weight", weight);
		}else {
			formData.append("type", 2);
		}					
		if (str !==undefined){
		  formData.append("str",str);
		}
		var xhr = new XMLHttpRequest();
		xhr.open('post', url, true);
		xhr.send(formData);
		console.log(id + ' ' + weight + ' ' + str);
		xhr.onreadystatechange = function() {
			if (xhr.readyState ==4) {
			  if ((xhr.status >=200 && xhr.status<300) || xhr.status ==304){
				isPost = true;
				console.log(xhr.responseText);
				 return !!xhr.responseText;
			  }
			  else {
			    alert("由于网络或其他原因导致无法购买,请关闭浏览器重试");
				console.log("cuowu");
			  }
			}
		}
	}
	var gohome = document.getElementById("gohome");
	gohome.onclick = function() {
	  sessionStorage.removeItem("position");
	}
	document.getElementById("productInfott").innerHTML=escapeHtml('{$goods['gdesc']}');
	document.getElementById("link-know").onclick=function(){
		document.querySelector('.link-rule').style.setProperty("display","none");
	}
	document.getElementById("lookdetail").onclick=function(){
		document.querySelector('.link-rule').style.setProperty("display","block");
	}
	function bb(b){
		var many_limit = $("#many_limit").val();
	    var one_limit = $("#one_limit").val();
	    var times = $("#times").val();
	    many_limit = parseInt(many_limit);
		one_limit=parseInt(one_limit);
		times=parseInt(times);
		if (isshow()) {
			if(b==1){
			location.href = "{php echo app_url('order/orderconfirm')}" + "&id=" + {$goods['id']}+ "&groupnum=1";
				//location.href = "{php echo app_url('order/orderconfirm',array(‘id’=>$goods['id'],'groupnum'=>1));}";
			}else{
			
				if(many_limit>=1){
						if(times >= many_limit){
							$.toast('单人购买总数为：'+many_limit+',您已购买'+times);
							return false;
						}
					}
				var nn = "{$goods['groupnum']}";
				
				location.href = "{php echo app_url('order/orderconfirm')}" + "&groupnum=" + nn+ "&id=" + {$goods['id']};
			}
		}
		else {
			$.toast("库存不足");
		}
	}
	
    $("#num").blur(function(){
		var inputnum=$("#num").val();
		var marketprice = 0;
	    var productprice = 0;
		var options = {php echo json_encode($options)};
		
		var ret = option_selected();
	    var len = options.length;
	        for (var i = 0; i < len; i++) {
	            var o = options[i];
	            var ids = ret.all.join("_");
	            if (o.specs == ids) {
	                optionid = o.id;
	                stock = o.stock;
	                marketprice = o.marketprice;
	                productprice = o.productprice;
	                break;
	            }
	        }
	    if(marketprice==0){
	     	marketprice = "{php echo $goods['gprice']}";
	    }
		var goodsPrice=marketprice;
		var totalPrice = goodsPrice*inputnum;
		totalPrice = totalPrice.toFixed(2);
		$("#option_gprice").html(totalPrice);
	});
	
	$("#up").bind('click',function(){
		var num = $('#num').val();
			num = parseInt(num)+1;
			$('#num').val(num);
		var marketprice = 0;
	    var productprice = 0;
		var options = {php echo json_encode($options)};
		var ret = option_selected();
	    var len = options.length;
	        for (var i = 0; i < len; i++) {
	            var o = options[i];
	            var ids = ret.all.join("_");
	            if (o.specs == ids) {
	                optionid = o.id;
	                stock = o.stock;
	                marketprice = o.marketprice;
	                productprice = o.productprice;
	                break;
	            }
	        }
	     if(marketprice==0){
	     	marketprice = "{php echo $goods['gprice']}";
	     }
		 if(productprice==0){
	     	productprice = "{php echo $goods['oprice']}";
	     }
		var goodsPrice=marketprice;
		var inputnum=num;
		var totalPrice = goodsPrice*inputnum;
		totalPrice = totalPrice.toFixed(2);
		$("#option_gprice").html(totalPrice);
		$("#option_oprice").html((productprice*inputnum).toFixed(2));
	});
	
	$("#down").bind('click',function(){
		var num = $('#num').val();
		num = parseInt(num)-1;
		if(num<=0){
			num=1;
		}
		$('#num').val(num);
		var marketprice = 0;
	    var productprice = 0;
		var options = {php echo json_encode($options)};
		var ret = option_selected();
	    var len = options.length;
	        for (var i = 0; i < len; i++) {
	            var o = options[i];
	            var ids = ret.all.join("_");
	            if (o.specs == ids) {
	                optionid = o.id;
	                stock = o.stock;
	                marketprice = o.marketprice;
	                productprice = o.productprice;
	                break;
	            }
	        }
	     if(marketprice==0){
	     	marketprice = "{php echo $goods['gprice']}";
	     }
		  if(productprice==0){
	     	productprice = "{php echo $goods['oprice']}";
	     }
		var goodsPrice=marketprice;
		var inputnum=num;
		var totalPrice = goodsPrice*inputnum;
		totalPrice = totalPrice.toFixed(2);
		$("#option_gprice").html(totalPrice);
		$("#option_oprice").html((productprice*inputnum).toFixed(2));
	});

   $("#num2").blur(function(){
	var inputnum=$("#num2").val();
	var gp=$("#gn").val();
		gp = inputnum * gp;
		$("#option_price").html(gp);
	});
	
	$("#up2").bind('click',function(){
		var num = $('#num2').val();
			num = parseInt(num)+1;
			$('#num2').val(num);
		var gp=$("#gn").val();
			gp = num * gp;
			$("#option_price").html(gp);
	});
	
	$("#down2").bind('click',function(){
		var num = $('#num2').val();
		num = parseInt(num)-1;
		if(num<=0){
			num=1;
		}
		$('#num2').val(num);
		var gp=$("#gn").val();
			gp = num * gp;
			$("#option_price").html(gp);
	});

    var options = {php echo json_encode($options)};
    var specs = {php echo json_encode($specs)};
    var hasoption = {php echo $goods['hasoption'] == '1' ? 'true' : 'false'};
	
    var selected = [];
    function option_selected() {
        var ret = {
            no: "",
            all: []
        };
        if (!hasoption) {
            return ret;
        }
        $(".optionid").each(function () {
            ret.all.push($(this).val());
            if ($(this).val() == '') {
                ret.no = $(this).attr("title");
                return false;
            }
        })
        return ret;
    }
	
	function closechoose(){
		$('.footer').show();
        $('.good_choose_layer').fadeOut(100);
		$('.good_choose').fadeOut(100); 
    }

	function exchange(numb) {
		$('#div_nav .boxx .sp').removeClass('on');
		$('.section_specification').removeClass('on');
		$('.section_detail').removeClass('on');
		$('a#shangpin'+numb).addClass('on');
		if(numb==0) {
			$('.section_specification').addClass('on');
		}else{
			$('.section_detail').addClass('on');
		}
	}
	
	function showStores(obj){
        if($(obj).attr('show')=='1'){
            $(obj).next('div').slideUp(100);
            $(obj).removeAttr('show').find('i').removeClass('fa-angle-down').addClass('fa-angle-up');
        }else{
            $(obj).next('div').slideDown(100);
            $(obj).attr('show','1').find('i').removeClass('fa-angle-up').addClass('fa-angle-down');
        }
    }
	function JTT() {
		var numPerson = document.getElementById("numPerson").textContent.split(",");
		var numPrices = document.getElementById("numPrices").textContent.split(",");
		var numGroup = document.getElementById("numGroup").textContent.split(",");
		var tuanPre = document.getElementById("tuanPre").textContent.split(",");
		var numTuan = tuanPre.length;
		var jtthtml = "";
		for (var j = 0; j < numTuan; j++) {
			jtthtml += '<div>'
				    + '<div>'
				    + '<div class="preTuan">团长:' + tuanPre[j] + '</div>'
					+ '<div class="numTuan">参团人数:' + numGroup[j] + '人</div>'
					+ '</div>'
					+ '<div class="process">'
					+ '<div class="progressBar"></div>'					
					+ '</div>'
					+ '<div class="payToGroup">我要参团' + j + '</div>'
					+ '</div>';	
		}		 
		var clickPayHandler;
		clickPayHandler = function (ev) {
			alert(ev.target.textContent);
			//alert("去支付");
		}
		var module = {};
		module.numPerson = numPerson;
		module.numPrices = numPrices;
		module.numTuan = numTuan;
		module.init = function() {
			var jieTiGroup = document.getElementById("jieTiGroup");
			jieTiGroup.insertAdjacentHTML('beforeend', jtthtml);
			for (var j = 0; j < this.numTuan; j++) {
				var progressBar = jieTiGroup.getElementsByClassName("progressBar")[j];
				progressBar.style.width = Math.round(Number(numGroup[j]) *100 / (Number(this.numPerson[this.numPerson.length - 1]) * 1.1)) + "%";
				var process = jieTiGroup.getElementsByClassName("process")[j];
				var payToGroup = jieTiGroup.getElementsByClassName("payToGroup")[j];
				payToGroup.onclick = clickPayHandler;
				for (var i = 0; i < this.numPerson.length; i++) {
					var div = document.createElement("div");
					div.className = "progressStep";
					div.style.right = Math.round(101 - Number(this.numPerson[i]) * 100 / (Number(this.numPerson[this.numPerson.length - 1]) * 1.1))  + "%";
					div.innerHTML = '<div>'+ this.numPerson[i] +'</div><div>'+ this.numPrices[i]+'</div>';
					process.appendChild(div);
				}
			}			
		}
		
		return module;
	}
	//JTT().init();
</script>
{php include wl_template('common/footer');}